#ifndef LEX_H
#define LEX_H

enum Token {
		TOKEN_TYPE_NONE     ,
		TOKEN_TYPE_INT      ,
		TOKEN_TYPE_FLOAT    ,
		TOKEN_TYPE_STRING   ,
		TOKEN_TYPE_PARAM    ,
		TOKEN_TYPE_IDENT    ,
		TOKEN_TYPE_COLON    ,
		TOKEN_TYPE_LBRACKET ,
		TOKEN_TYPE_RBRACKET ,
		TOKEN_TYPE_COMMA    ,
		TOKEN_TYPE_LBRACE   ,
		TOKEN_TYPE_RBRACE   ,
		TOKEN_TYPE_NEWLINE  ,
		TOKEN_TYPE_INSTR    ,
		TOKEN_TYPE_SETSTACKSIZE ,
		TOKEN_TYPE_VAR      ,
		TOKEN_TYPE_FUNC     ,
		TOKEN_TYPE_REG_RETVAL   ,
		TOKEN_TYPE_INVALID      ,
		END_OF_TOKEN_STREAM     ,
	};


class Lex {
public:
	

	struct TLine {
        //TLine(): _data(), _lineInFile(0) {}
		string       _data;
		int	         _lineInFile;
	};

public:
	Lex();
	int   loadFile(const char *file);
	Token getNextToken();
	void  saveToken(Token token);
	void  skipLine();
	void  resetLex();
	void  addInstr(vector<string> &nameList);
	int   getCurrLine();
    const string &getCurrLexme() const { return _tempName; }

private:
	void  stripComments(char *line);
	void  trim(char *line);

private:
	vector<TLine> _lines;
	string       _tempName;
	Token        _svToken;
	int          _line;
	int	         _col;
	
	map<char, Token> _token_map;
	map<string, Token> _Ident_map;

private:
	static const char  _comment = ';';
};


#endif
